package bold.shiro;


import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthenticatedException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 统一异常处理
 */
@RestControllerAdvice
@Slf4j
public class ExceptionController {

    @ExceptionHandler(AuthorizationException.class)
    public Object authorizationException(AuthorizationException ex) {
        log.error("", ex);
        return "没登录";
    }

    @ExceptionHandler({UnauthorizedException.class, UnauthenticatedException.class})
    public Object unauthorizedException(Exception ex) {
        log.error("", ex);
        return "没权限1";
    }


}
